<?php
/**
 * 缓存类
 *
 * @author 陈小飞
 * @version  2008-2-29
 * @copyright 陈小飞
 */
 
class MemcachedCache {	
	public $cacheObj; 
	  
	/**
	 * 构造函数
	 */
	function __construct() {	
		global $G;
		//$this->fileName = $global['path']['cache']. 'u'.UID.'.php';
		
		$this->cacheObj = new Memcache();	//12000	
		//$this->cacheObj->connect(SYS_CACHE_IP, SYS_CACHE_PROT) or die ("Could not connect");
		$this->cacheObj->connect($G['memcache_host'], $G['memcache_port']) or die ('EEOR:C');
		//if(!$this->cacheObj->get(UID)){
//			$this->cacheObj->set(UID,array('caveInfo','caveLayer'));
//		}
		
		return $this->cacheObj;
		
	}//end __construct


	public function get($key) {
		if(!$key){return false;}
		return $this->cacheObj->get($key);
	}
	
	
	public function set($key,$value,$flag=0,$timeOut=3600) {		//MEMCACHE_COMPRESSED
		
		//if(!$key){echo '::::'.$key;return false;}
		return $this->cacheObj->set($key,$value,$flag,$timeOut);
	}
	public function add($key,$value) {
		return $this->cacheObj->add($key,$value);
	}
	public function delete($key) {
		if(strlen($key)==''){return false;}
		return $this->cacheObj->delete($key);
	}
	public function flush() {
		return $this->cacheObj->flush();
	}
	
}
?>